package comms;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class CommsTestOutgoing extends MIDlet {
	private static CommsTestOutgoing instance;
	private TextBox textBox;
	private ConnectionManager manager;
	private DatagramAgentConnection outgoing;
	private AgentConnection test;
	
	public CommsTestOutgoing() {
		super();
		CommsTestOutgoing.instance = this;
		textBox = new TextBox("Comms Test MIDlet", "Testing...", 25, 0);
		
		/*
		 * Comms Testing instantiation.
		 */
		this.outgoing = new DatagramAgentConnection(7777, "192.168.0.3");
		try {
			while(true) {
				this.outgoing.sendAgent(new MobileAgent("bl;ah"));
				System.out.println("sent 1");
			}
		} catch (Exception e) {System.err.println(e.getMessage());e.printStackTrace();}
		
	}
	
	public static CommsTestOutgoing getInstance() {
		return CommsTestOutgoing.instance;
	}
	
	public void startApp() {
		this.display();
	}
	
	public void pauseApp() {
		
	}
	
	public void display() {
		Display.getDisplay(this).setCurrent(textBox);
	}
	
	public void destroyApp(boolean dest) {
		CommsTestOutgoing.instance = null;
	}
} 
